How hard is FizzBuzz? [closed]
Posted
by Josh K
on Stack Overflow
See other posts from Stack Overflow
or by Josh K
Published on 2010-04-16T23:28:27Z
Indexed on
2010/04/16
23:33 UTC
Read the original article
Hit count: 437
After reading various blog entries I took it upon myself to code a FizzBuzz program in PHP.
class FizzBuzz
{
function __construct()
{
}
function go()
{
for($i = 1; $i < 101; $i++)
{
if($i % 3 == 0 and $i % 5 == 0)
{
echo("FizzBuzz\n");
continue;
}
else if($i % 3 == 0)
{
echo("Fizz\n");
continue;
}
else if($i % 5 == 0)
{
echo("Buzz\n");
continue;
}
else
{
echo($i."\n");
}
}
}
}
$FB = new FizzBuzz();
$FB->go();
Created the FizzBuzz
object just because I could, I complete this in under five minutes.
Is it really that hard to do?
© Stack Overflow or respective owner